/*
 * BitBoardOps.h
 *
 *  Created on: 2012-11-26
 *      Author: Larry.Li
 */

#ifndef BITBOARDOPS_H_
#define BITBOARDOPS_H_

#define BITBOARD_AND(leftOperand,rightOperand) leftOperand.startingBits &= rightOperand.startingBits;\
											   leftOperand.middleBits &= rightOperand.middleBits;\
											   leftOperand.endingBits &= rightOperand.endingBits
#define BITBOARD_OR(leftOperand,rightOperand) leftOperand.startingBits |= rightOperand.startingBits;\
											  leftOperand.middleBits |= rightOperand.middleBits;\
											  leftOperand.endingBits |= rightOperand.endingBits
#define BITBOARD_XOR(leftOperand,rightOperand) leftOperand.startingBits ^= rightOperand.startingBits;\
											   leftOperand.middleBits ^= rightOperand.middleBits;\
               	   	   	   	   	   	   	   	   leftOperand.endingBits ^= rightOperand.endingBits
#define BITBOARD_ANDNOT(leftOperand,rightOperand) leftOperand.startingBits &= ~rightOperand.startingBits;\
											   leftOperand.middleBits &= ~rightOperand.middleBits;\
               	   	   	   	   	   	   	   	   leftOperand.endingBits &= ~rightOperand.endingBits
#define BITBOARD_ANDEMPTY(board) board.startingBits &= 0x0;\
								board.middleBits &= 0x0;\
								board.endingBits &= 0x0

extern BitBoard bitBoardAND(BitBoard *leftOperand, BitBoard *rightOperand);
extern BitBoard bitBoardOR(BitBoard *leftOperand, BitBoard *rightOperand);
extern BitBoard bitBoardXOR(BitBoard *leftOperand, BitBoard *rightOperand);
extern int isBitBoardEmpty(BitBoard *board);
extern void bitBoardLeftShift(BitBoard *bitBoard, int bits);
extern BitBoard getFileBitBoardFromLowest10Bits(unsigned long bits,
		int fileIndex);
extern BitBoard getRankBitBoardFromLowest9Bits(unsigned long bits,
		int rankIndex);
extern unsigned long getBitBoardBitsOfRank(int rankNum, BitBoard *board);
extern unsigned long getRotatedBitBoardBitsOfRank(int rankNum, BitBoard *board);
extern int countBitBoardTotalBits(BitBoard *bitBoard);
extern int bitBoardLSB(BitBoard *bitBoard);
extern int bitBoardMSB(BitBoard *bitBoard);
extern int count32(unsigned long arg);
extern int lsb32(unsigned long arg);
extern int msb32(unsigned long arg);
extern void setChessPosition(int chess, int thisPosition,
		ChessPosition *allPosition);
extern void unsetChessPosition(int thisPosition, ChessPosition *allPosition);

#endif /* BITBOARDOPS_H_ */
